package com.kly.test.base

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.kly.test.base.adpater.SimpleObserverAdapter
import io.reactivex.disposables.Disposable

class LifecycleObserver(private val disposable: Disposable) : LifecycleObserver {
    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    fun dispose() {
        disposable.dispose()
        if (disposable is SimpleObserverAdapter<*>) {
            disposable.release()
        }
    }
}
